const mongoose = require('mongoose');
mongoose.Promise = Promise;
mongoose.connect("mongodb://127.0.0.1/blog",{
    user: "mai852852",
    pass: "mai6800909",
    poolSize: 10
});// 连接数据库，建立持久连接


 // mongoose.connect("mongodb://127.0.0.1/blog");
const db = mongoose.connection;

db.on("open",  function(){
    console.log("打开数据库成功！");
});
db.on("error",  function(error, stdout, stderr){
    console.log("数据库打开失败 请尝试开启mongo服务");
    return;

});


module.exports=mongoose;